<?php
include_once 'icn/config.php';
include_once 'icn/mysql.class.php';
include_once 'icn/myfunction.php';
	if ($_GET['do']=="edit") {
	$mysql =new mysql();
	$mysql->open($dbconfig);
	$mysql->update("`listdeta` = '$_POST[listdeta]'", "banshichu","`id`=$_POST[id]");
	$table = "";
	echo "<script language='javascript'>";
	echo "location='banshichu.php?do=select&order_id=$_GET[order_id]';";
	echo "</script>";
	}else {
	$banshichu_id = $_GET['banshichu_id'];
	$mysql =new mysql();
	$mysql->open($dbconfig);
	$banshichu = $mysql->get_one("`id`,`order_id`,`banshi`,`newdate`,`listdeta`", "banshichu","`id`=$banshichu_id");
	//print_r($banshichu);;
	$table = json_tabel($banshichu[listdeta]);
	};
?>


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<script type="text/javascript" src = "images/jquery.js"></script>
<script type="text/javascript" src = "images/edittable.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript">
function postdate(){
	var jsonarray = [];
	var tr = $('#edittable tr');
	for(i=1;i<tr.length;i++){
			var td = $('td',tr[i]);
			var data = "{";
			data +="\"yanse\":\""+td[0].innerHTML+"\"";
			data +=(parseInt(td[1].innerHTML)>0)?",\"s\":"+parseInt(td[1].innerHTML):"";
			data +=(parseInt(td[2].innerHTML)>0)?",\"m\":"+parseInt(td[2].innerHTML):"";
			data +=(parseInt(td[3].innerHTML)>0)?",\"l\":"+parseInt(td[3].innerHTML):"";
			data +=(parseInt(td[4].innerHTML)>0)?",\"xl\":"+parseInt(td[4].innerHTML):"";
			data +=(parseInt(td[5].innerHTML)>0)?",\"xxl\":"+parseInt(td[5].innerHTML):"";
			data +=(parseInt(td[6].innerHTML)>0)?",\"xxxl\":"+parseInt(td[6].innerHTML):"";
			data +="}";
			jsonarray.push(data);
		};
	var jsondata = "{\"banshichu\":["+jsonarray.join(",")+"]}";
	$("#listdeta").val(jsondata);
	$("form").submit();
}


</script>
<title>Insert title here</title>
</head>
<body>

<form action="?do=edit&order_id=<?php echo $banshichu[order_id]?>" method="post">
<input type="hidden" name="id" id="id" value="<?php echo $banshichu[id]?>"/>
<input type="hidden" name="listdeta" id="listdeta" value=""/>
</form>
<!--输出列表-->
<?php echo  $table ?> 
<input type="button" onClick="postdate()"  value="修改"/>
</body>
</html>